from abc import ABC, abstractmethod

# 一共是两个抽象类，和三个具体类
class Live(ABC):
    def __init__(self, name, age=1):
        self._name = name
        self._age = age

    def eat(self):
        print(f'{self}在吃饭')

    def play(self):
        print(f'{self}在玩')

    def sleep(self):
        print(f'{self}在睡觉')

    def __str__(self) -> str:
        return f'名字是{self._name}，年龄{self._age}岁的{self.__class__.__name__}'

class Animal(Live,ABC):
    @abstractmethod
    def work(self):
        pass

class Dog(Animal):
    def watch(self):
        print(f'{self}在看家')

    def work(self):
        self.watch()

class Cat(Animal):
    def cat_mouse(self):
        print(f'{self}在捉老鼠')

    def work(self):
        self.cat_mouse()
    
class Person(Live):
    def __init__(self, name, pets, age=1):
        super().__init__(name, age)
        self._pets = pets

    def yang(self):
        print(__name__)
        for pet in self._pets:
            pet.eat()
            pet.play()
            pet.sleep()

    # 这个方法如何省略
    def work(self):
        pass

    def let_pets_work(self):
        for pet in self._pets:
            pet.work()

def main():
    dog = Dog('wyl351')
    cat = Cat('wyl352')

    person = Person('wyl350',[dog, cat],43)

    person.yang()
    person.let_pets_work()
    print(person)

if __name__ == '__main__':
    main()
    